﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Maticsoft.DBUtility;
public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string username = userName.Text;
        string password = passWord.Text;
        string sql = "select ID from TB_UserInfo where userName=" + AddQuotes(username) + " and userPassword=" + AddQuotes(password) + "";
        object obj = DbHelperOleDb.GetSingle(sql);
        if (obj!=null)
        {
            UserModel model = new UserModel(obj.ToString(), username, password);
            Session["318User"] = model;
            Response.Write("<script>alert('登录成功!');window.location.href ='../index.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('用户名或密码错误!');</script>");
        }

    }
    private string AddQuotes(string str)
    {
        return "'" + str + "'";
    }
}